#ifndef __CSV_PARSER_H__
#define __CSV_PARSER_H__

#include "dynamic_array.h"
#include "raylib.h"
#include "types.h"
#define DYN_STR_IMPLEMENTATION
#include "dynamic_string.h"
#include "convert.h"

#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600
#define TARGET_FPS 144
#define MARGIN 10
#define PREVIEW_LINES 10
#define FONT_SIZE 20
#define POINTER_RADIUS MARGIN*0.5
#define POINTER_COLOR RED

typedef struct ColTypes {
    ColumnType *items;
    u64 length;
    u64 capacity;
} ColTypes;

typedef struct ColSelected {
    bool *items;
    u64 length;
    u64 capacity;
} ColSelected;

typedef struct ColDateType {
    u64 *items;
    u64 length;
    u64 capacity;
} ColDateType;

typedef struct Data {
    void **items;
    u64 length;
    u64 capacity;
    ColTypes types;
} Data;

typedef struct picker_window {
    i32 x;
    i32 y;
    i32 width;
    i32 height;
    i32 margin;
    u32 font_size;
    Color list_color;
    const char *pcwd;
    String_Builder *cwd;
    String_Builder *csv_path;
    String_View csv_path_view;
    String_Builder_Array *csv_paths;
    bool new_file_picked;
} picker_window;

typedef struct preview_csv_window {
    i32 x;
    i32 y;
    i32 width;
    i32 height;
    i32 margin;
    u32 font_size;
    Color grid_bg;
    Color grid_lines;
    String_Builder *csv_raw;
    String_View cwd_view;
    String_View csv_raw_rows;
    String_View csv_raw_columns;
    String_Builder_Array_2D *raw_csv;
    String_Builder_Array_2D *raw_csv_full;
    String_Builder_Array_2D *raw_csv_col;
    String_Builder_Array_2D *raw_csv_col_full;
    String_Builder *header_count_str;
    i64 header_count;
    ColTypes *column_types;
    ColSelected *column_type_selected;
    ColSelected *column_date_type_selected;
    HashList *date_format_hash;
    String_Builder_Array *date_formats;
    ColDateType *col_date_type;
    Data *data;
    String_Builder_Array *hl_sb;
    HashArray *hl_ha;
    bool transpose_raw_csv;
    bool convert_columns;
} preview_csv_window;


#endif // __CSV_PARSER_H__